package ui;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseWheelListener;
import org.eclipse.swt.widgets.Composite;

import Music_Playing.Music_Playing;

public class VolumeBar extends AbstractProgressBar {

	
	public VolumeBar(Composite parent, int style) {
		super(parent, style);
		addMouseWheelListener(new MouseWheelListener() {
			
			@Override//鼠标滚轮事件
			public void mouseScrolled(MouseEvent e) {
				if (e.count < 0) {
					double temp = progress + 0.05;
					progress = temp > 1.0 ? 1.0 : temp;
				}else {
					double temp = progress - 0.05;
					progress = temp < 0.0 ? 0.0 : temp;
				}
				//TODO progress以改变
			}
		});
	}
	
	@Override
	public void mouseUp(MouseEvent e) {
		super.mouseUp(e);
		try {
			Music_Playing.setVolume(progress);
		} catch (Exception e2) {
		}
	}

}
